# Maintainer: Christoph Reiter <reiter.christoph@gmail.com>

_realname=minidump-stackwalk
_projectname=rust-minidump
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.25.0
pkgrel=1
pkgdesc="Provides both machine-readable and human-readable digests of a minidump, with backtraces and symbolication (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://github.com/rust-minidump/rust-minidump'
msys2_references=(
  'aur: minidump-stackwalk'
  'purl: pkg:cargo/minidump-stackwalk'
)
license=('spdx:MIT')
makedepends=("${MINGW_PACKAGE_PREFIX}-rust")
source=("${url}/archive/v${pkgver}/${_realname}-${pkgver}.tar.gz")
sha256sums=('432ad72fb9c8a451d217e815227125d4befa91155560ec616e5556f0797c7185')

prepare() {
  cp -r "${_projectname}-${pkgver}" "build-${MSYSTEM}" && cd "build-${MSYSTEM}"

  cargo fetch --locked --target "$(rustc -vV | sed -n 's/host: //p')"
}

build() {
  cd "build-${MSYSTEM}"

  cargo build --release --frozen -p minidump-stackwalk
}

check() {
  cd "build-${MSYSTEM}"

  cargo test --release --frozen -p minidump-stackwalk
}

package() {
  cd "build-${MSYSTEM}"

  cargo install \
    --frozen \
    --offline \
    --no-track \
    --path minidump-stackwalk \
    --root "${pkgdir}${MINGW_PREFIX}"

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
